package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.pickLedOff
import com.hontech.bread.device.pickLedOn
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class PickLedParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_pick_led, this)
        val btnOpen = view.findViewById<Button>(R.id.id_pick_led_btn_on)
        val btnClose = view.findViewById<Button>(R.id.id_pick_led_btn_off)

        btnOpen.onClick {
            runProg(stringById(R.string.t1733460848_426), stringById(R.string.t1733460848_427)) {
                pickLedOn()
            }
        }

        btnClose.onClick {
            runProg(stringById(R.string.t1733460848_428), stringById(R.string.t1733460848_429)) {
                pickLedOff()
            }
        }
    }
}
